//
//  XZLeaveInfoDynamicCell.m
//  Teecloud
//
//  Created by PC on 2018/11/7.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "XZLeaveInfoDynamicCell.h"
#import "XZAuditInfo.h"
@interface XZLeaveInfoDynamicCell()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableViewHeight;
@property (nonatomic, strong) NSMutableArray *dataSource;
@end




@implementation XZLeaveInfoDynamicCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
}
- (void)setAuditInfo:(NSArray *)AuditInfo{
    _AuditInfo = AuditInfo;
    self.tableViewHeight.constant = 45 *AuditInfo.count + 10;
    [self.dataSource removeAllObjects];
    [self.dataSource addObjectsFromArray:AuditInfo];
    [self.tableView reloadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    XZAuditInfo *model = self.dataSource[indexPath.row];
    if ([model.Flag isEqualToString:@"1"]) {
        cell.textLabel.textColor = kRedColor;
    }
    cell.textLabel.font = [UIFont systemFontOfSize:14.0f];
    cell.textLabel.text  = model.Info;
    return cell;
}
- (NSMutableArray *)dataSource{
    if (!_dataSource) {
        _dataSource = [[NSMutableArray alloc]init];
    }
    return _dataSource;
}
@end
